import React from 'react'
import '../css/Sendheaders.css'
import eventEmitter from '../event'
class Sendheaders extends React.Component {
	render() {
		return (
			<div className="header">
				<div className="w">
					<div className="list">
						<h1>TODOLIST</h1>
						<div>
							<input
								type="text"
								className="send"
								placeholder="添加ToDo"
								onKeyDown={(e) => {
									if (e.keyCode === 13) {
                    let value = e.target.value
                    let message = {
											content: value,
										}
										if (value === '') {
											alert('内容不能为空！')
										} else {
											eventEmitter.emit('sendmessage', message) //抛出携带value自定义事
										}
									

										e.target.value = ''
										// console.log(123);
									}
								}}
							/>
						</div>
					</div>
				</div>
			</div>
		)
	}
}

export default Sendheaders
